/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercises.day02.pt03;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

/**
 *
 * @author (jaice)
 * may 29, 2012
 * 
 * b. Create an application that breaks down pocket money in terms of coins. 
 * For example, a change of Php 25.70 would break down to: (2) 10 peso coins, 
 * (1) 5 peso coin, (2) 25-centavo coin, and (2) 10-centavo coin.  Add each coin 
 * to a collection and display the result.
 * 
 */
public class PocketMoney {

   

    public PocketMoney(double money) {

        //declare collection
        TreeMap<String, Integer> coins = new TreeMap<String, Integer>();


        coins.put("A. 10 peso coins    ", (int) (money / 10));
        coins.put("B. 5 peso coins     ", (int) (money % 10) / 5);
        coins.put("C. 1 peso coins     ", (int) (money % 10) % 5);
        coins.put("D. 25 centavo coins ", (int) ((money * 100) % 100) / 25);
        coins.put("E. 10 centavo coins ", (int) (((money * 100) % 100) % 25) / 10);
        coins.put("F. 1 centavo coins  ", (int) (((money * 100) % 100) % 25) % 10);

        //first get the set of key values aka type of coin
        Set<String> keys = coins.keySet();



        for (String key : keys) {

            System.out.printf("(%d)  %s %n", coins.get(key), key);
        }


    }

    public static void main(String args[]) {
        double amt = 0;
        //declare scanner
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter amount to be converted to coins");
        amt = sc.nextDouble();


        PocketMoney pm = new PocketMoney(amt);



    }
}
